#pragma once

#include <QObject>
#include <d3d9.h>
#include <QThread>
#include <functional>
#include <list>
/// <summary>
/// 屏幕录制线程
/// </summary>
class TonyCaptureScreen:protected QThread
{
private:
	//1 创建directx3d对象
	IDirect3D9* d3d = nullptr;
	//创建显卡的设备对象
	IDirect3DDevice9* device = nullptr;
	//创建离屏表面
	IDirect3DSurface9* sur = nullptr;
	//屏幕宽度
	int screenWidth = 0;
	//屏幕高度
	int screenHeight = 0;
	bool isRecording = false;
	std::list<char*> screenData;
	void Init();
	void OnCaptureScreen(void* data);
	void Close();
	
public:
	QString outFilePath;
	static TonyCaptureScreen* Get()
	{
		static TonyCaptureScreen tcs;
		return &tcs;
	}
	void run()override;
	void Start();
	void Stop();
	std::list<char*> getScreenDataList();
	int getLinesize();
	int getWidth();
	int getHeight();
	~TonyCaptureScreen();
public:
	int fps = 15;
protected:
	TonyCaptureScreen();
};
